/*    */ package com.newcrm.webapi.sub;
/*    */ 
/*    */ import com.newcrm.bean.User;
/*    */ import com.newcrm.db.ExportTaskManager;
/*    */ import com.newcrm.exception.DBException;
/*    */ import com.newcrm.exception.NotFoundException;
/*    */ import com.newcrm.util.Util;
/*    */ import com.newcrm.webapi.AbstractAction;
/*    */ import com.newcrm.webapi.AbstractHttpServlet;
/*    */ import java.io.IOException;
/*    */ import java.io.PrintWriter;
/*    */ import java.util.List;
/*    */ import javax.servlet.ServletException;
/*    */ import javax.servlet.http.HttpServletRequest;
/*    */ import javax.servlet.http.HttpServletResponse;
/*    */ import net.sf.json.JSONObject;
/*    */ import org.apache.log4j.Logger;
/*    */ 
/*    */ public class ListCustomerExportHistory extends AbstractAction
/*    */ {
/* 35 */   private static Logger logger = Logger.getLogger(ListCustomerExportHistory.class.getName());
/*    */ 
/*    */   public ListCustomerExportHistory(AbstractHttpServlet servlet) {
/* 38 */     super(servlet);
/*    */   }
/*    */ 
/*    */   public void parse(HttpServletRequest request, HttpServletResponse response)
/*    */     throws IOException, ServletException, NotFoundException
/*    */   {
/* 44 */     User user = super.getLoginUser(request);
/* 45 */     int offset = Util.getURLIntParameter(request.getParameter("offset"));
/*    */ 
/* 47 */     ExportTaskManager manager = new ExportTaskManager();
/*    */     try {
/* 49 */       List result = manager.list(offset, 
/* 50 */         user.companyId, user.userId);
/* 51 */       response.setContentType("text/html;charset=utf-8");
/* 52 */       PrintWriter out = response.getWriter();
/* 53 */       JSONObject jsonObject = new JSONObject();
/* 54 */       jsonObject.put("error", "0");
/* 55 */       jsonObject.put("list", result);
/* 56 */       if (offset == 0) {
/* 57 */         int totalNums = manager
/* 58 */           .getTotalNum(user.companyId, user.userId);
/* 59 */         jsonObject.put("totalNums", Integer.valueOf(totalNums));
/* 60 */         int totalPages = totalNums / 10;
/* 61 */         if (totalNums % 10 > 0) {
/* 62 */           totalPages++;
/*    */         }
/* 64 */         jsonObject.put("totalPages", Integer.valueOf(totalPages));
/*    */       }
/* 66 */       out.println(jsonObject);
/* 67 */       out.flush();
/* 68 */       out.close();
/* 69 */       return;
/*    */     } catch (DBException e) {
/* 71 */       logger.warn("load export history failed", e);
/* 72 */       super.showErrorMessage(response, "加载导出记录失败，请稍后重试");
/*    */     }
/*    */   }
/*    */ }

/* Location:           C:\E\referenceProject\CRM参考\qikebao\WEB-INF\lib\qikebao.jar
 * Qualified Name:     com.newcrm.webapi.sub.ListCustomerExportHistory
 * JD-Core Version:    0.6.1
 */